﻿#pragma once

#include "Const.h"
#include "PictureCtrl.h"

// 游戏
class Game {
    // 难度
    public: enum Difficulty {
        EASY = 9,       // 简单
        MEDIUM = 25,    // 中等
        HARD = 36       // 困难
    };

    // 状态
    public: enum Status {
        END,    // 已结束
        PLAYING // 游戏中
    };

    private: CWnd* mCallback;           // 回调
    private: Difficulty mDifficulty;    // 难度
    private: CDC* mDrawer;              // 绘图者
    private: CPoint mEmptyPoint;        // 空点，即没有图的那个点
    private: CWnd* mGameBoard;          // 游戏区域
    private: CBitmap mImage;            // 图片
    private: CDC mImageDC;              // 图片保存者
    private: BOOL mPicHasBorder;        // 图片控件是否有边框标志
    private: PictureCtrl* mPictures[Const::MAX_PICTURE_CTRL_COUNT]; // 图片控件数组
    private: Status mStatus;            // 状态

    public: Game(CWnd*, CDC*, CWnd*);
    public: virtual ~Game();
    private: void CreatePictures();
    private: void DeletePictures();
    public: void DrawPictures();
    private: void GameOver();
    public: Difficulty GetDifficulty();
    public: Status GetStatus();
    private: BOOL IsWon();
    public: void MovePicture(UINT);
    public: BOOL PictureHasBorder();
    public: void SetDifficulty(Difficulty);
    public: void SetPicture(CImage*);
    public: void SetPictureBorder(BOOL);
    public: void Start();
    private: void SwapPictures(int, int);
};
